/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package upgmdendro.drawing.drawables;

import upgmdendro.drawing.*;
import java.awt.Point;

/**
 *
 * @author psychollek
 */
public class DrawableDiagramObject implements Drawable {

    private Drawable object = null;
    private DrawableLine connector = null;

    public DrawableDiagramObject(double start, double end, int position, int oStart, int oEnd) {
        int h = GraphicParameters.getHeight();
        int iStart = Math.round(Math.round(20 + ((h - 40) * start)));
        int iEnd = Math.round(Math.round(20 + ((h - 40) * end)));
        
        connector = new DrawableLine(new Point(position, iStart),
                new Point(position, iEnd));
        object = new DrawableLine(new Point(oStart, iStart),
                new Point(oEnd, iStart));
    }

    public DrawableDiagramObject(double start, double end, int position, String name) {
        int h = GraphicParameters.getHeight();
        int iStart = Math.round(Math.round(20 + ((h - 40) * start)));
        int iEnd = Math.round(Math.round(20 + ((h - 40) * end)));

        connector = new DrawableLine(new Point(position, iStart),
                new Point(position, iEnd));
        object = new DrawableText(name, position - 3, iStart - 11);
    }

    @Override
    public void paint() {
        object.paint();
        connector.paint();
    }
}
